package main

import "fmt"

//map的遍历
func main() {
	m := make(map[string]string, 10)
	m["a"] = "hello"
	m["b"] = "world"
	for key, value := range m {
		fmt.Println("key=", key, "value=", value)
	}

	//二维map
	student1 := make(map[string]string, 10)
	student2 := make(map[string]string, 10)
	col := make(map[string]map[string]string, 10)
	student1["stuno"] = "1001"
	student1["stuName"] = "ceshi"
	student1["stuAddres"] = "henan"
	student2["stuno"] = "1002"
	student2["stuName"] = "ceshi2"
	student2["stuAddres"] = "henan2"

	col["student1"] = student1
	col["student2"] = student2
	fmt.Println(col)

	//还可以取出具体的值
	fmt.Println(col["student1"])
	fmt.Println(col["student1"]["stuName"])
	for key, value := range col {
		fmt.Println("key=", key)
		for k, v := range value {
			fmt.Printf("\tkey=%v,value=%v\n", k, v)
		}
	}

	fmt.Println(len(m))
}
